home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / Trackdisk.mod < prev    next >
Text File  |  1995-06-29  |  8KB  |  270 lines

  1. (**************************************************************************
  2.  
  3.      $RCSfile: Trackdisk.mod $
  4.   Description: trackdisk device structure and value definitions
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.8 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:13:14 $
  10.  
  11.   $VER: trackdisk.h 33.13 (28.11.90)
  12.   Includes Release 40.15
  13.  
  14.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  15.       All Rights Reserved
  16.  
  17.   Oberon-A interface Copyright © 1994-1995, Frank Copeland.
  18.   This file is part of the Oberon-A Interface.
  19.   See Oberon-A.doc for conditions of use and distribution.
  20.  
  21. ***************************************************************************)
  22.  
  23. <* STANDARD- *>
  24.  
  25. MODULE [2] Trackdisk;
  26.  
  27. IMPORT e := Exec, s := Sets;
  28.  
  29.  
  30. (*
  31.  *--------------------------------------------------------------------
  32.  *
  33.  * Physical drive constants
  34.  *
  35.  *--------------------------------------------------------------------
  36.  *)
  37.  
  38. CONST
  39.  
  40.   numSecs * = 11;
  41.   numUnits * = 4;
  42.  
  43. (*
  44.  *--------------------------------------------------------------------
  45.  *
  46.  * Useful constants
  47.  *
  48.  *--------------------------------------------------------------------
  49.  *)
  50.  
  51. CONST
  52.  
  53. (* -- sizes before mfm encoding *)
  54.   sector * = 512;
  55.   secShift * = 9;           (* log tdSECTOR *)
  56.  
  57. (*
  58.  *--------------------------------------------------------------------
  59.  *
  60.  * Driver Specific Commands
  61.  *
  62.  *--------------------------------------------------------------------
  63.  *)
  64.  
  65.  
  66. CONST
  67.  
  68.   name * = "trackdisk.device";
  69.  
  70.   extCom * = -10000H;              (* for internal use only! *)
  71.  
  72.  
  73.   motor *        = e.nonstd+0;  (* control the disk's motor *)
  74.   seek *         = e.nonstd+1;  (* explicit seek (for testing) *)
  75.   format *       = e.nonstd+2;  (* format disk *)
  76.   remove *       = e.nonstd+3;  (* notify when disk changes *)
  77.   changeNum *    = e.nonstd+4;  (* number of disk changes *)
  78.   changeState *  = e.nonstd+5;  (* is there a disk in the drive? *)
  79.   protStatus *   = e.nonstd+6;  (* is the disk write protected? *)
  80.   rawRead *      = e.nonstd+7;  (* read raw bits from the disk *)
  81.   rawWrite *     = e.nonstd+8;  (* write raw bits to the disk *)
  82.   getDriveType * = e.nonstd+9;  (* get the type of the disk drive *)
  83.   getNumTracks * = e.nonstd+10; (* # of tracks for this type drive *)
  84.   addChangeInt * = e.nonstd+11; (* tdREMOVE done right *)
  85.   remChangeInt * = e.nonstd+12; (* remove softint set by ADDCHANGEINT *)
  86.   getGeometry *  = e.nonstd+13; (* gets the disk geometry table *)
  87.   eject *        = e.nonstd+14; (* for those drives that support it *)
  88.   lastComm *     = e.nonstd+15;
  89.  
  90. (*
  91.  *
  92.  * The disk driver has an "extended command" facility.  These commands
  93.  * take a superset of the normal IO Request block.
  94.  *
  95.  *)
  96.  
  97. CONST
  98.  
  99.   extWrite *       = e.write  + extCom;
  100.   extRead *        = e.read   + extCom;
  101.   extMotor *       = motor    + extCom;
  102.   extSeek *        = seek     + extCom;
  103.   extFormat *      = format   + extCom;
  104.   extUpdate *      = e.update + extCom;
  105.   extClear *       = e.clear  + extCom;
  106.   extRawRead *     = rawRead  + extCom;
  107.   extRawWrite *    = rawWrite + extCom;
  108.  
  109. (*
  110.  *
  111.  * extended IO has a larger than normal io request block.
  112.  *
  113.  *)
  114.  
  115. TYPE
  116.  
  117.   IOExtTDPtr * = POINTER TO IOExtTD;
  118.   IOExtTD * = RECORD (e.IORequestBase)
  119.     req *      : e.IOStdReq;
  120.     count *    : e.ULONG;
  121.     secLabel * : e.ULONG;
  122.   END; (* IOExtTD *)
  123.  
  124. (*
  125.  *  This is the structure returned by tdDRIVEGEOMETRY
  126.  *  Note that the layout can be defined three ways:
  127.  *
  128.  *  1. TotalSectors
  129.  *  2. Cylinders and CylSectors
  130.  *  3. Cylinders, Heads, and TrackSectors.
  131.  *
  132.  *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
  133.  *  are usable, though #2 and #3 may waste some portion of the available
  134.  *  space on some drives.
  135.  *)
  136.  
  137. TYPE
  138.  
  139.   DriveGeometryPtr * = POINTER TO DriveGeometry;
  140.   DriveGeometry * = RECORD
  141.     sectorSize *   : e.ULONG;  (* in bytes *)
  142.     totalSectors * : e.ULONG;  (* total # of sectors on drive *)
  143.     cylinders *    : e.ULONG;  (* number of cylinders *)
  144.     cylSectors *   : e.ULONG;  (* number of sectors/cylinder *)
  145.     heads *        : e.ULONG;  (* number of surfaces *)
  146.     trackSectors * : e.ULONG;  (* number of sectors/track *)
  147.     bufMemType *   : e.ULONG;  (* preferred buffer memory type *)
  148.                                (* (usually memfPUBLIC) *)
  149.     deviceType *   : SHORTINT; (* codes as defined in the SCSI-2 spec *)
  150.     flags *        : s.SET8;   (* flags, including removable *)
  151.     reserved *     : e.UWORD;
  152.   END; (* DriveGeometry *)
  153.  
  154. CONST
  155.  
  156. (* device types *)
  157.   directAccess *         = 0;
  158.   sequentialAccess *     = 1;
  159.   printer *              = 2;
  160.   processor *            = 3;
  161.   worm *                 = 4;
  162.   cdRom *                = 5;
  163.   scanner *              = 6;
  164.   opticalDisk *          = 7;
  165.   mediumChanger *        = 8;
  166.   communication *        = 9;
  167.   unknown *              = 31;
  168.  
  169. (* flags *)
  170.   removable *           = 0;
  171.  
  172. (*
  173. ** raw read and write can be synced with the index pulse.  This flag
  174. ** in io request's ioFLAGS field tells the driver that you want this.
  175. *)
  176.  
  177.   indexSync * = 4;
  178. (*
  179. ** raw read and write can be synced with a $4489 sync pattern.  This flag
  180. ** in io request's ioFLAGS field tells the driver that you want this.
  181. *)
  182.   wordSync *  = 5;
  183.  
  184.  
  185. (* labels are tdLabelSize bytes per sector *)
  186.  
  187.   labelSize * = 16;
  188.  
  189. (*
  190. ** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
  191. ** the driver will allow you to open all the disks that the trackdisk
  192. ** driver understands.  Otherwise only 3.5" disks will succeed.
  193. *)
  194.  
  195.   allowNon35 *       = 0;
  196.  
  197. (*
  198. **  If you set the tdbAllowNon35 bit in OpenDevice, then you don't
  199. **  know what type of disk you really got.  These defines are for the
  200. **  tdGETDRIVETYPE command.  In addition, you can find out how many
  201. **  tracks are supported via the tdGETNUMTRACKS command.
  202. *)
  203.  
  204.   drive35 *        = 1;
  205.   drive525 *       = 2;
  206.   drive35150rpm *  = 3;
  207.  
  208. (*
  209.  *--------------------------------------------------------------------
  210.  *
  211.  * Driver error defines
  212.  *
  213.  *--------------------------------------------------------------------
  214.  *)
  215.  
  216. CONST
  217.  
  218.   notSpecified *      = 20;      (* general catchall *)
  219.   noSecHdr *          = 21;      (* couldn't even find a sector *)
  220.   badSecPreamble *    = 22;      (* sector looked wrong *)
  221.   badSecID *          = 23;      (* ditto *)
  222.   badHdrSum *         = 24;      (* header had incorrect checksum *)
  223.   badSecSum *         = 25;      (* data had incorrect checksum *)
  224.   tooFewSecs *        = 26;      (* couldn't find enough sectors *)
  225.   badSecHdr *         = 27;      (* another "sector looked wrong" *)
  226.   writeProt *         = 28;      (* can't write to a protected disk *)
  227.   diskChanged *       = 29;      (* no disk in the drive *)
  228.   seekError *         = 30;      (* couldn't find track 0 *)
  229.   noMem *             = 31;      (* ran out of memory *)
  230.   badUnitNum *        = 32;      (* asked for a unit > NUMUNITS *)
  231.   badDriveType *      = 33;      (* not a drive that trackdisk groks *)
  232.   driveInUse *        = 34;      (* someone else allocated the drive *)
  233.   postReset *         = 35;      (* user hit reset; awaiting doom *)
  234.  
  235. (*
  236.  *--------------------------------------------------------------------
  237.  *
  238.  * public portion of the unit structure
  239.  *
  240.  *--------------------------------------------------------------------
  241.  *)
  242.  
  243. TYPE
  244.  
  245.   PublicUnitPtr * = POINTER TO PublicUnit;
  246.   PublicUnit * = RECORD (e.UnitBase)
  247.     unit *           : e.Unit;   (* base message port *)
  248.     comp01Track *    : e.UWORD;  (* track for first precomp *)
  249.     comp10Track *    : e.UWORD;  (* track for second precomp *)
  250.     comp11Track *    : e.UWORD;  (* track for third precomp *)
  251.     stepDelay *      : e.ULONG;  (* time to wait after stepping *)
  252.     settleDelay *    : e.ULONG;  (* time to wait after seeking *)
  253.     retryCnt *       : SHORTINT; (* # of times to retry *)
  254.     pubFlags *       : s.SET8;   (* public flags, see below *)
  255.     currTrk *        : e.UWORD;  (* track the heads are over... *)
  256.                                  (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  257.     calibrateDelay * : e.ULONG;  (* time to wait after stepping *)
  258.                                  (* during a recalibrate *)
  259.     counter *        : e.ULONG;  (* counter for disk changes... *)
  260.                                  (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  261.   END; (* PublicUnit *)
  262.  
  263. CONST
  264.  
  265. (* flags for tduPubFlags *)
  266.   noClick *    = 0;
  267.  
  268.  
  269. END Trackdisk.
  270.